﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>红动五月</title>
    <link rel="stylesheet" type="text/css" href="../css/index.css">
	<link rel="stylesheet" type="text/css" href="../css/weui.css" />
    
    <script type="text/javascript" src="../js/jquery-1.7.2-min.js"></script>
	<script type="text/javascript" src="../js/common/common.js"></script>
	<script type="text/javascript" src="../js/rem.js"></script>
	
	<script type="text/javascript" src="../js/wejs/zepto.min.js"></script>
    <script type="text/javascript" src="../js/wejs/jweixin-1.0.0.js"></script>
    <script type="text/javascript" src="../js/alert-common/common.js"></script>
	
</head>
<body>
    <div class="content">
		<div class="button" onclick="jump();"></div>
    </div>
    
    <script type="text/javascript">
	
		var rootPath = getRootPath();

		function jump() {
			$.ajax({
				headers: {"Cookie" : document.cookie },
				type : "POST",
				url : rootPath + "/pointActivity/api/v1/initPage",
				//url : "http://localhost:9013/pointActivity/api/v1/initPage",
				dataType : "json",
				async : false,
				contentType : "application/json",
				success : function(json) {
					
					if(json.resultCode == 1){
						
						var resultData = JSON.parse(json.data);
						
						if(check(resultData)){
							
							// 售后
							if(resultData.activityType == 0){
								window.location.href = rootPath + "/views/sh.html?date=" + new Date();
							} 
							
							// 销售
							if(resultData.activityType == 1){
								window.location.href = rootPath + "/views/xs.html?date=" + new Date();
							}
							
						} else {
							return ;
						}
					} else {
						weAlert(json.errMsg);
					}
					
				}
			});
		}
		
		function check(resultData){
			
			if(resultData.hasOwnProperty("isRepeat")){
				if(resultData.isRepeat){
					weAlert("您已抽取，更多活动，敬请关注广汽三菱服务号！祝您用车愉快！");
					return false;
				}
			} else if (resultData.hasOwnProperty("isVinRepeat")){
				if(resultData.isVinRepeat){
					weAlert("您的车辆已参加活动！");
					return false;
				}
			} else {
				
				if(resultData.userType == 100001 && typeof(resultData.userType) != "undefined"){
					weAlert("请注册会员.",function(){
						window.location.href = rootPath + "/views/homepage/signUp.html?my_sysdate=" + new Date();
					});
					return false;
				}
				
				if(resultData.userType == 100002 && typeof(resultData.userType) != "undefined"){
					weAlert("请认证车辆.",function(){
						window.location.href = rootPath + "/views/homepage/Authentication.html?my_sysdate=" + new Date();
					});
					return false;
				}

				if(resultData.userType == 100000 && typeof(resultData.userType) != "undefined"){
					weAlert("活动参与人数过多，请稍后再试！");
					return false;
				}
				
				if(resultData.userType == 100004 && typeof(resultData.userType) != "undefined"){
					weAlert("经销商尚未开票,请与经销商联系.");
					return false;
				}
				
				if(resultData.activityType == 2 && typeof(resultData.activityType) != "undefined"){
					weAlert("没有可参加的活动.");
					return false;
				}
				
				if(resultData.activityIsEnd == "false" && typeof(resultData.activityIsEnd) != "undefined"){
					weAlert("活动已下线.更多活动敬请关注！");
					return false;
				}
				
				if(resultData.activityIsStart == "false" && typeof(resultData.activityIsStart) != "undefined"){
					weAlert("活动尚未开始.敬请期待！");
					return false;
				}
				
				if(resultData.getPointStatus == "fail"){
					weAlert("活动礼包已发放完毕，下次活动不见不散！");
					return false;
				}
				
				if(resultData.surplusPacke == "false" && typeof(resultData.surplusPacke) != "undefined"){
					weAlert("活动礼包已发放完毕，下次活动不见不散！");
					return false;
				}
				
			}
			
			return true;
		}
	</script>
</body>
</html>